#include<cstdio>
#include<cstring>
#include<algorithm>
#define INF 0x3f3f3f3f
using namespace std;
typedef long long LL;
typedef double db;
inline int read()
{
	int x=0,f=1;
	char ch=getchar();
	while(ch<'0'||ch>'9') { if(ch=='-')f=-1; ch=getchar(); }
	while(ch>='0'&&ch<='9') { x=(x<<1)+(x<<3)+ch-'0'; ch=getchar(); }
	return x*f;
}
const int MAXN=2.5e5+10;
int n,m;
char str1[MAXN],str2[MAXN];
struct SAM
{
	int root,lst,cnt;
	struct node
	{
		int ch[26],par,val;
	}a[MAXN<<1];
	int newnode(int x)
	{
		a[++cnt].val=x;
		return cnt;
	}
	void init()
	{
		cnt=0;
		root=lst=newnode(0);
	}
	void extend(int c)
	{
		int np=newnode(a[lst].val+1),p=lst;
		while(p&&!a[p].ch[c])a[p].ch[c]=np,p=a[p].par;
		if(!p)a[np].par=root;
		else if(a[a[p].ch[c]].val==a[p].val+1)a[np].par=a[p].ch[c];
		else 
		{
			int nq=newnode(a[p].val+1),q=a[p].ch[c];
			memcpy(a[nq].ch,a[q].ch,sizeof(a[q].ch));
			a[nq].par=a[q].par;
			a[q].par=a[np].par=nq;
			while(p&&a[p].ch[c]==q)a[p].ch[c]=nq,p=a[p].par;
		}
		lst=np;
	}
	int find()
	{
		int ret=0,sum=0,x=root;
		for(int i=1;i<=m;++i)
		{
			int c=str2[i]-'a';
			if(a[x].ch[c])ret=max(ret,++sum),x=a[x].ch[c];
			else
			{
				while(x&&!a[x].ch[c])x=a[x].par;
				if(!x)x=root,sum=0;
				else
				{
					ret=max(ret,sum=a[x].val+1);
					x=a[x].ch[c];
				}
			}
		}
		return ret;
	}
}M1;
int main()
{
	scanf("%s%s",str1+1,str2+1);
	n=strlen(str1+1),m=strlen(str2+1);
	M1.init();
	for(int i=1;i<=n;++i)M1.extend(str1[i]-'a');
	printf("%d\n",M1.find());
	return 0;
}
